package com.songshuai.sales.tool.feign;

import com.songshuai.webapi.baseapi.dto.UserUpdatePwdDto;
import com.songshuai.webapi.baseapi.dto.feign.request.UserAddReqDto;
import com.songshuai.webapi.baseapi.dto.feign.request.UserInfoUpdateReqDto;
import com.songshuai.webapi.baseapi.dto.feign.response.*;
import com.songshuai.webapi.baseapi.pojo.QueryPageRes;
import com.songshuai.webapi.baseapi.pojo.QueryResponse;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Created by yubo on 2018/11/15.
 */

@FeignClient(name = "permission")
public interface PermissionClient {

    //用户ID获取用户信息
    //QueryResponse queryUserById(@RequestHeader(value = "Authorization", required = true) String token, @RequestParam("id") Integer id);
    @GetMapping(value = "/api/users/queryUserById")
    QueryResponse queryUserById(@RequestHeader(value = "Authorization") String token, @RequestParam("id") Integer id);

    //获取用户列表（1,2,3）
    @GetMapping(value = "/api/departments/queryUsersForStr")
    QueryResponse queryUsersForStr(@RequestHeader(value = "Authorization") String token, @RequestParam("ids") String ids);

    //校区ID获取用户
    @GetMapping(value = "/api/users/getUsersByCampusId")
    QueryResponse getUsersByCampusId(@RequestHeader(value = "Authorization") String token, @RequestParam("id") Integer campusId, @RequestParam(value = "isAll", required = false) Boolean isAll);

    //根据登录用户名获取当前用户信息
    @GetMapping(value = "/api/users/getCurrentUser")
    QueryResponse getCurrentUser(@RequestHeader(value = "Authorization") String token, @RequestParam("username") String username);

    /**
     * 根据用户名或手机号模糊查询
     * @param account
     * @param status
     * @param pageIndex
     * @param pageSize
     * @return
     */
    @PostMapping("/api/user/queryUserInfoListByPage")
    QueryResponse<QueryPageRes<List<AccountPageLIstResDto>>> queryAccountListByPage(@RequestHeader(value = "Authorization") String token
            , @RequestParam("account") String account
            , @RequestParam("status") Integer status
            , @RequestParam("pageIndex") int pageIndex
            , @RequestParam("pageSize") int pageSize);

    /**
     * 根据角色查询菜单以及功能
     * @param roleIds
     * @return
     */
    @PostMapping("/api/user/queryFunctionByRole")
    QueryResponse<Map<Integer,List<NavAndFuncByRoleResDto>>> queryFunctionByRole(@RequestHeader(value = "Authorization") String token, @RequestParam("roleIds") List<Integer> roleIds);


    /**
     * 根据菜单id获取菜单信息
     * @param ids 菜单id集合
     * @return
     */
    @PostMapping("/api/user/queryNavigationInfo")
    QueryResponse<Map<Integer, NavigationInfoResDto>> queryNavigationInfo(@RequestHeader(value = "Authorization") String token, @RequestParam("ids") List<Integer> ids);



    /**
     * 根据功能id获取功能信息
     * @param ids 功能id集合
     * @return
     */
    @PostMapping("/api/user/queryFunctionInfo")
    QueryResponse<Map<Integer, FunctionInfoResDto>> queryFunctionInfo(@RequestHeader(value = "Authorization") String token, @RequestParam("ids") List<Integer> ids);




    /**
     * 新增用户
     * @param request
     * @return
     */
    @PostMapping("/api/user/addUser")
    QueryResponse addUser(@RequestHeader(value = "Authorization") String token, @RequestBody UserAddReqDto request);


    /**
     * 根据用户id查询用户信息
     * @param id
     * @return
     */
    @PostMapping("/api/user/queryUserInfoById")
    QueryResponse<AccountInfoResDto> queryUserInfoById(@RequestHeader(value = "Authorization") String token, @RequestParam("id") Integer id);


    /**
     * 修改用户信息
     * @param requset
     * @return
     */
    @PostMapping("/api/user/updateUserById")
    QueryResponse updateUserById(@RequestHeader(value = "Authorization") String token, @RequestBody UserInfoUpdateReqDto requset);


    /**
     * 禁用/启用
     * @param id
     * @return
     */
    @GetMapping("/api/user/updateUserStatusById")
    QueryResponse updateUserStatusById(@RequestHeader(value = "Authorization") String token, @RequestParam("id") Integer id, @RequestParam("status") Integer status);


    /**
     * 根据用户id修改密码
     * @param id
     * @param pwd
     * @return
     */
    @GetMapping("/api/user/updateUserPwdById")
    QueryResponse updateUserPwdById(@RequestHeader(value = "Authorization") String token, @RequestParam("id") Integer id, @RequestParam("pwd") String pwd);


    /**
     * 删除用户
     * @param id
     * @return
     */
    @GetMapping("/api/user/deleteUserById")
    QueryResponse deleteUserById(@RequestHeader(value = "Authorization") String token, @RequestParam("id") Integer id);

    /**
     * 修改用户密码
     */
    @PostMapping(value = "/api/users/updateUserPwd",consumes = MediaType.APPLICATION_JSON_VALUE)
    QueryResponse updateUserPassword(@RequestHeader(value = "Authorization") String token, @RequestBody UserUpdatePwdDto userUpdatePwdDto);


    //根据多个用户id查询用户信息
    @PostMapping("/api/user/queryUserInfoByIds")
    QueryResponse<List<AccountInfoListResDto>> queryUserInfoByIds(@RequestHeader(value = "Authorization") String token, @RequestBody List<Integer> userIds);

    //根据多个用户id查询用户信息
    @PostMapping("/api/user/queryUserInfoListByCampusId")
    QueryResponse<List<AccountInfoListResDto>> queryUserInfoListByCampusId(@RequestHeader(value = "Authorization") String token, @RequestParam("userId") Integer userId, @RequestParam("campusId") Integer campusId);

    //根据真实姓名模糊查询用户信息
    @PostMapping("/api/user/queryUserInfoListByTrueName")
    QueryResponse<List<AccountInfoListResDto>> queryUserInfoListByTrueName(@RequestHeader(value = "Authorization") String token, @RequestParam("trueName") String trueName, @RequestParam("campusId") Integer campusId);
}



